<?php
	if(empty($_GET["roomID"])) {
		die('Room ID cannot be empty');
	}
	
	$roomID = $_GET["roomID"];
	$studentID = $_GET["studentID"];
	
	$con = mysql_connect("localhost","root","");
	if (!$con) {
		die('Could not connect: ' . mysql_error());
	}
	mysql_select_db("ciu196", $con);
	
	$sql = "DELETE FROM StudentsInRooms WHERE studentID = '$studentID' AND roomID = '$roomID'";
		if(!mysql_query($sql,$con)) {
			die('Error couldnt delete from StudentsInRooms: ' . mysql_error());
		}
	
	
	$sql = "DELETE FROM helpqueue WHERE studentID = '$studentID' AND roomID = '$roomID'";
		if(!mysql_query($sql,$con)) {
			die('Error couldnt delete from help queue: ' . mysql_error());
		}
	
	
	$echo "Student left the room";
	
	mysql_close($con);	
?>